package run.microservice.stock.response;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author Lundy
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BusinessException extends RuntimeException {
    private ResultEnum resultEnum;
    private String[] args;

    public BusinessException(ResultEnum resultEnum) {
        super(resultEnum.getMsg());
        this.resultEnum = resultEnum;
    }

    /**
     * @param resultEnum 结果枚举
     * @param arg 消息参数
     */
    public BusinessException(ResultEnum resultEnum, String arg) {
        super(resultEnum.getMsg());
        String[] args = new String[]{arg};
        this.resultEnum = resultEnum;
        this.args = args;
    }

    /**
     * @param resultEnum 结果枚举
     * @param args 消息参数数组
     */
    public BusinessException(ResultEnum resultEnum, String[] args) {
        super(resultEnum.getMsg());
        this.resultEnum = resultEnum;
        this.args = args;
    }

}
